home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dfpp01.zip / TESTAPPL.CPP < prev    next >
C/C++ Source or Header  |  1992-11-21  |  5KB  |  160 lines

  1. // ------- testappl.cpp
  2.  
  3. #include <stdio.h>
  4.  
  5. #include "dflatpp.h"
  6. #include "testappl.h"
  7.  
  8. TestAppl    *ApWnd = NULL;
  9. ListBox     *LsWnd = NULL;
  10. TextBox     *TxWnd = NULL;
  11. TextBox     *EdWnd = NULL;
  12. PushButton  *PBWnd = NULL;
  13. CheckBox    *CBWnd = NULL;
  14. RadioButton *RBWnd1 = NULL;
  15. RadioButton *RBWnd2 = NULL;
  16.  
  17. extern MenuBarItem MainMenu[];
  18. extern MenuSelection TextBoxCommand;
  19. extern MenuSelection ListBoxCommand;
  20. extern MenuSelection EditBoxCommand;
  21. extern MenuSelection PushButtonCommand;
  22. extern MenuSelection CheckBoxCommand;
  23. extern MenuSelection RadioButtonCommand;
  24. extern MenuSelection InsertCommand;
  25.  
  26. extern unsigned _stklen = 8192;
  27.  
  28. void main()
  29. {
  30.     // ------- application window
  31.     ApWnd = new TestAppl("Testing D-Flat++", MainMenu);
  32.     ApWnd->SetAttribute(SIZEABLE | MOVEABLE);
  33.     ApWnd->BuildInsertMode();
  34.     // ---- initiate processing
  35.     while (desktop.DispatchEvents())
  36.         ;
  37.     delete ApWnd;
  38.     delete LsWnd;
  39.     delete TxWnd;
  40.     delete EdWnd;
  41.     delete PBWnd;
  42.     delete CBWnd;
  43.     delete RBWnd1;
  44.     delete RBWnd2;
  45. }
  46.  
  47. void TestAppl::BuildListBox()
  48. {
  49.     ListBoxCommand.Disable();
  50.     // --------- build a listbox
  51.     LsWnd = new ListBox("Listbox 1", 23, 7, 10, 20, ApWnd);
  52.     LsWnd->SetAttribute(BORDER |
  53.                         CONTROLBOX |
  54.                         MINBOX |
  55.                         MAXBOX |
  56.                         MOVEABLE | SIZEABLE |
  57.                         SHADOW | VSCROLLBAR);
  58.     char *le = "List Entry #  ";
  59.     for (int i = 0; i < 100; i++)    {
  60.         sprintf(le+12, "%d", i+1);
  61.         LsWnd->AddText(le);
  62.     }
  63.     LsWnd->SetFocus();
  64. }
  65.  
  66. void TestAppl::BuildTextBox()
  67. {
  68.     TextBoxCommand.Disable();
  69.     // ------- build a textbox
  70.     TxWnd = new TextBox("Textbox", 20, 10, 12, 45, ApWnd);
  71.     TxWnd->SetAttribute( BORDER | CONTROLBOX |
  72.                         MINBOX | MAXBOX | MOVEABLE |
  73.                         SIZEABLE | SHADOW | HSCROLLBAR | VSCROLLBAR);
  74.     TxWnd->Show();
  75.     TxWnd->AddText("Now is the time for all good men");
  76.     TxWnd->AddText("to come to the aid of their party");
  77.     TxWnd->AddText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
  78.     TxWnd->AddText("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
  79.     TxWnd->AddText("cccccccccccccccccccccccccccccccccccccccc");
  80.     TxWnd->AddText("dddddddddddddddddddddddddddddddddddddddd");
  81.     TxWnd->AddText("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
  82.     TxWnd->AddText("ffffffffffffffffffffffffffffffffffffffff");
  83.     TxWnd->AddText("gggggggggggggggggggggggggggggggggggggggg");
  84.     TxWnd->AddText("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
  85.     TxWnd->AddText("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
  86.     TxWnd->AddText("jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
  87.     TxWnd->AddText("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
  88.     TxWnd->AddText("llllllllllllllllllllllllllllllllllllllll");
  89.     TxWnd->AddText("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
  90.     TxWnd->AddText("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
  91.     TxWnd->AddText("oooooooooooooooooooooooooooooooooooooooo");
  92.     TxWnd->AddText("pppppppppppppppppppppppppppppppppppppppp");
  93.     TxWnd->AddText("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");
  94.     TxWnd->AddText("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr");
  95.     TxWnd->AddText("ssssssssssssssssssssssssssssssssssssssss");
  96.     TxWnd->AddText("tttttttttttttttttttttttttttttttttttttttt");
  97.     TxWnd->AddText("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu");
  98.     TxWnd->SetFocus();
  99. }
  100.  
  101. void TestAppl::BuildEditBox()
  102. {
  103.     EditBoxCommand.Disable();
  104.     // ------- build an editbox
  105.     EdWnd = new EditBox("Editbox", 5, 15, 3, 20, ApWnd);
  106.     EdWnd->SetAttribute( BORDER | CONTROLBOX |
  107.                         MINBOX | MOVEABLE |
  108.                         SIZEABLE | SHADOW );
  109.     EdWnd->SetFocus();
  110. }
  111.  
  112. void TestAppl::BuildPushButton()
  113. {
  114.     PushButtonCommand.Disable();
  115.     // ------- build a pushbutton
  116.     PBWnd = new PushButton("~Test Button", 5, 15, ApWnd);
  117.     PBWnd->SetAttribute( SHADOW );
  118.     PBWnd->SetButtonFunction(this, APWND::ButtonPushed);
  119.     PBWnd->SetFocus();
  120. }
  121.  
  122. void TestAppl::ButtonPushed()
  123. {
  124.     desktop.speaker().Beep();
  125. }
  126.  
  127. void TestAppl::BuildCheckBox()
  128. {
  129.     CheckBoxCommand.Disable();
  130.     // ------- build a check box
  131.     CBWnd = new CheckBox("~Check Box", 5, 17, ApWnd);
  132.     CBWnd->SetFocus();
  133. }
  134.  
  135. void TestAppl::BuildRadioButton()
  136. {
  137.     RadioButtonCommand.Disable();
  138.     // ------- build a check box
  139.     RBWnd1 = new RadioButton("Radio Button ~1", 5, 19, ApWnd);
  140.     RBWnd2 = new RadioButton("Radio Button ~2", 5, 20, ApWnd);
  141.     RBWnd1->SetFocus();
  142.     RBWnd2->Show();
  143.     RBWnd1->PushRadioButton();
  144. }
  145.  
  146. void TestAppl::BuildInsertMode()
  147. {
  148.     if (InsertCommand.isToggled())
  149.         desktop.keyboard().SetInsertMode();
  150.     else 
  151.         desktop.keyboard().ClearInsertMode();
  152. }
  153.  
  154. void TestAppl::Exit()
  155. {
  156.     ApWnd->CloseWindow();
  157. }
  158.  
  159.  
  160.